package com.fowo.api.controller.purchase;

import com.fowo.api.common.model.ImportRow;
import com.fowo.api.common.model.R;
import com.fowo.api.controller.purchase.importPo.AdjustmentOrderProductCountPo;
import com.fowo.api.controller.purchase.importPo.AdjustmentOrderProductSwapPo;
import com.fowo.api.controller.purchase.importPo.StockInProductImportPo;
import com.fowo.api.model.adjustment.order.product.AdjustmentOrderProductItemVo;
import com.fowo.api.service.handleWork.AdjustmentOrderProductDServiceImpl;
import com.fowo.api.service.handleWork.StockInProductDServiceImpl;
import com.fowo.api.sys.entity.SysFile;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "调整单子表")
@RequestMapping("/api/adjustment-order-product")
@RestController
public class AdjustmentOrderProductDController {

    @Resource
    private AdjustmentOrderProductDServiceImpl service;

    @Operation(summary = "换标调整导入预览")
    @PostMapping("/import-preview-swap")
    public R<List<AdjustmentOrderProductItemVo>> importPreviewSwap(@RequestBody SysFile sysFile,
                                                                   @RequestParam(name = "template", required = false) Long templateId,
                                                                   @RequestParam(name = "wid", required = false) Long wid,
                                                                   @RequestParam(name = "allowOverrides",defaultValue = "false") boolean allowOverrides)
    {
        return R.data(() -> service.importPreviewSwap(sysFile,templateId,allowOverrides,wid));
    }


    @Operation(summary = "数量调整导入预览")
    @PostMapping("/import-preview-count")
    public R<List<AdjustmentOrderProductItemVo>> importPreviewCount(@RequestBody SysFile sysFile,
                                                                                @RequestParam(name = "template", required = false) Long templateId,
                                                                                @RequestParam(name = "wid", required = false) Long wid,
                                                                                @RequestParam(name = "allowOverrides",defaultValue = "false") boolean allowOverrides) {
        return R.data(() -> service.importPreviewCount(sysFile,templateId,allowOverrides,wid));
    }

}
